<?php
/**
 * 《报价》实用类
 *
 * @author 孙晓晔
 * @version $Id: QuoteUtil.class.php 1037 2010-03-26 11:47:59Z sunxy $
 */
require_once(dirname(__FILE__) . '/../AdminUtil.class.php');

class QuoteUtil extends AdminUtil {
	
	public $type = array(
		'-' => '请选择',
		'1' => '产品',
		'2' => '产品',
		'3' => '改模',
		'4' => '运费',
		'5' => '热流道',
	
		'9' => '其它',
	);
	
	public $category = array(
		'-' => '请选择',
		'1' => '出口模',
		'2' => '国内模',
		'3' => '注塑',
		'9' => '其它',
	);
	
	function __construct() {
		$request['update'] = '$Date: 2009/03/03 07:24:42 $';
		$request['revision'] = '$Revision: 1.5 $';
			
		parent::__construct($request);
	}

	function pretreat($controller) {
		parent::pretreat($controller);
				
		$controller->assign_by_ref('type_option', $this->type);
		
		$controller->assign_by_ref('category_option', $this->category);
	}

	function _my() {
		if ($this->_audit('5')) {
			return '';
		}

		$emp = $_SESSION['id'];

		return sprintf("(emp in (%s) OR bj = '%s')", $this->leader($emp), $emp);
	}	

	/**
	 * 判断是否有信息
	 *
	 * @param integer $quote
	 * @return boolean
	 */
	function exist_info($quote) {
		$db = newdb($this->dsn_r);
		$fmt = "SELECT * FROM %s WHERE quote = '%s'";
		$sql = sprintf($fmt, Constant::tbl_quote_info, $quote);
		$result = $db->query($sql);
		// debug($sql);
		if ($db->num_rows($result) > 0) {
			return true;
		}

		return false;
	}
}